// Package user 存放用户 Model 相关逻辑
package models

import (
	"books/pkg/database"
)

// Category 用户模型
type Category struct {
	BaseModel

	Name string `json:"name,omitempty"`

	CommonTimestampsField
}

func GetCategories() ([]Category, error) {
	var categories []Category
	err := database.DB.Model(Category{}).Find(&categories).Error
	return categories, err
}

func (t *Category) CreateCategory() error {
	err := database.DB.Create(&t).Error
	return err
}
